<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="../../../style.css" type="text/css" media="screen">
<link rel="stylesheet" href="../../../print.css" type="text/css" media="print">
<meta content="MathUtil,jp.raohmaru.utils.MathUtil,chaos,checkRange,random,randomBit,randomBool,randomGreyColor,randomHexColor,randomInt,randomSign,toDegree,toRadian" name="keywords">
<title>jp.raohmaru.utils.MathUtil</title>
</head>
<body>
<script type="text/javascript" language="javascript" src="../../../asdoc.js"></script><script type="text/javascript" language="javascript" src="../../../cookies.js"></script><script type="text/javascript" language="javascript">
<!--
				asdocTitle = 'MathUtil - Raohmaru AS3 Framework';
				var baseRef = '../../../';
				window.onload = configPage;
			--></script>
<table style="display:none" id="titleTable" cellspacing="0" cellpadding="0" class="titleTable">
<tr>
<td align="left" class="titleTableTitle">Raohmaru AS3 

Framework</td><td align="right" class="titleTableTopNav"><a onclick="loadClassListFrame('../../../all-classes.html')" href="../../../package-summary.html">All&nbsp;Packages</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../all-classes.html')" href="../../../class-summary.html">All&nbsp;Classes</a>&nbsp;|&nbsp;<a onclick="loadClassListFrame('../../../index-list.html')" href="../../../all-index-A.html">Index</a>&nbsp;|&nbsp;<a href="../../../index.html?jp/raohmaru/utils/MathUtil.html&amp;jp/raohmaru/utils/class-list.html" id="framesLink1">Frames</a><a onclick="parent.location=document.location" href="" style="display:none" id="noFramesLink1">No&nbsp;Frames</a></td><td rowspan="3" align="right" class="titleTableLogo"><img alt="Adobe Logo" title="Adobe Logo" class="logoImage" src="../../../images/logo.jpg"></td>
</tr>
<tr class="titleTableRow2">
<td align="left" id="subTitle" class="titleTableSubTitle">Class&nbsp;MathUtil</td><td align="right" id="subNav" class="titleTableSubNav"><a href="#methodSummary">Methods</a></td>
</tr>
<tr class="titleTableRow3">
<td colspan="2">&nbsp;</td>
</tr>
</table>
<script type="text/javascript" language="javascript">
<!--
if (!isEclipse() || window.name != ECLIPSE_FRAME_NAME) {titleBar_setSubTitle("Class MathUtil"); titleBar_setSubNav(false,false,false,false,false,false,true,false,false,false,false,false,false,false);}
--></script>
<div class="MainContent">
<table cellspacing="0" cellpadding="0" class="classHeaderTable">
<tr>
<td class="classHeaderTableLabel">Package</td><td><a onclick="javascript:loadClassListFrame('class-list.html')" href="package-detail.html">jp.raohmaru.utils</a></td>
</tr>
<tr>
<td class="classHeaderTableLabel">Class</td><td class="classSignature">public class MathUtil</td>
</tr>
</table>
<p></p>
 Conjunto de métodos que extienden la funcionalidad de la clase Math.
 <p></p>
<p>
<span class="classHeaderTableLabel">See also</span>
</p>
<div class="seeAlso">Math</div>
<br>
<hr>
</div>
<a name="methodSummary"></a>
<div class="summarySection">
<div class="summaryTableTitle">Public Methods</div>
<table id="summaryTableMethod" class="summaryTable " cellpadding="3" cellspacing="0">
<tr>
<th>&nbsp;</th><th colspan="2">Method</th><th class="summaryTableOwnerCol">Defined&nbsp;by</th>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#chaos()">chaos</a>(min:int, max:int = 0, decimal:int = 0):Array</div>
<div class="summaryTableDescription">[static]
 Devuelve una lista desordenada de valores entre el rango especificado, ambos inclusive.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#checkRange()">checkRange</a>(n:int, range_start:int, range_end:int = 0):int</div>
<div class="summaryTableDescription">[static]
  Determina si un número entero está dentro del rango de valores (valor mínimo y máximo inclusive), y en caso de sobrepasarlo lo adecúa a los límites del rango.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#random()">random</a>(min:Number, max:Number, decimal:int = 0):Number</div>
<div class="summaryTableDescription">[static]
 Devuelve un valor de coma flotante aleatorio entre un valor mínimo y un valor máximo.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomBit()">randomBit</a>(prob:Number = 50):int</div>
<div class="summaryTableDescription">[static]
 Devuelve aleatoriamente 0 ó 1 según la probabilidad estimada.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomBool()">randomBool</a>(prob:Number = 50):Boolean</div>
<div class="summaryTableDescription">[static]
 Devuelve un valor booleano aleatorio según la probabilidad estimada.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomGreyColor()">randomGreyColor</a>(min:uint = 255, max:uint = 0):uint</div>
<div class="summaryTableDescription">[static]
  Devuelve un valor entero sin signo aleatorio correspondiente a una gama de color gris, del blanco al negro.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomHexColor()">randomHexColor</a>():uint</div>
<div class="summaryTableDescription">[static]
  Devuelve un entero sin signo aleatorio entre 0x0 y 0xFFFFFF.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomInt()">randomInt</a>(min:int = 1, max:int = 0):int</div>
<div class="summaryTableDescription">[static]
 Devuelve un valor entero aleatorio entre un valor mínimo y un valor máximo.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#randomSign()">randomSign</a>(prob:Number = 50):int</div>
<div class="summaryTableDescription">[static]
 Devuelve aleatoriamente -1 ó 1 según la probabilidad estimada.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#toDegree()">toDegree</a>(radianes:Number):Number</div>
<div class="summaryTableDescription">[static]
 Convierte un valor en radianes a grados.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
<tr class="">
<td class="summaryTablePaddingCol">&nbsp;</td><td class="summaryTableInheritanceCol">&nbsp;</td><td class="summaryTableSignatureCol">
<div class="summarySignature">
<a class="signatureLink" href="#toRadian()">toRadian</a>(grados:Number):Number</div>
<div class="summaryTableDescription">[static]
 Convierte un valor en grados a radianes.</div>
</td><td class="summaryTableOwnerCol">MathUtil</td>
</tr>
</table>
</div>
<script type="text/javascript" language="javascript">
<!--
showHideInherited();
--></script>
<div class="MainContent">
<a name="methodDetail"></a>
<div class="detailSectionHeader">Method detail</div>
<a name="chaos()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">chaos</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td>
</tr>
</table>
<div class="detailBody">
<code>public static function chaos(min:int, max:int = 0, decimal:int = 0):Array</code><p>
 Devuelve una lista desordenada de valores entre el rango especificado, ambos inclusive.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">min</span>:int</code> &mdash; Inicio de la lista
 </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">max</span>:int</code> (default = <code>0</code>)<code></code> &mdash; Fin de la lista
 </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">decimal</span>:int</code> (default = <code>0</code>)<code></code> &mdash; Convierte el valor en un número de coma flotante y desplaza la coma la cantidad de decimales especificados
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Array</code> &mdash; Array
 </td>
</tr>
</table>
</div>
<a name="checkRange()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">checkRange</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function checkRange(n:int, range_start:int, range_end:int = 0):int</code><p>
  Determina si un número entero está dentro del rango de valores (valor mínimo y máximo inclusive), y en caso de sobrepasarlo lo adecúa a los límites del rango.
  </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">n</span>:int</code> &mdash; El número a comprobar
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">range_start</span>:int</code> &mdash; Inicio del rango (o fin del rango si no se especifica <code>range_end</code>)
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">range_end</span>:int</code> (default = <code>0</code>)<code></code> &mdash; Fin del rango
  </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>int</code></td>
</tr>
</table>
</div>
<a name="random()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">random</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function random(min:Number, max:Number, decimal:int = 0):Number</code><p>
 Devuelve un valor de coma flotante aleatorio entre un valor mínimo y un valor máximo.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">min</span>:Number</code> &mdash; Valor inferior (o máximo si no se especifica <code>max</code>)
 </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">max</span>:Number</code> &mdash; Valor superior
 </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">decimal</span>:int</code> (default = <code>0</code>)<code></code> &mdash; Convierte el valor en un número de coma flotante y desplaza la coma la cantidad de decimales especificados
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; Number
 </td>
</tr>
</table>
<br>
<span class="label">Example</span>
<br> <div class='listing'><pre>
 import jp.raohmaru.utils.MathUtil;

 trace( MathUtil.random() );  // 0.35709940269589424
 trace( MathUtil.random(10) );  // 7.056785519234836
 trace( MathUtil.random(-5, 5) );  // -0.1471709879115224
 trace( MathUtil.random(0, .99, 2) );  // 0.37
 </pre></div>
 <p></p>
</div>
<a name="randomBit()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomBit</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomBit(prob:Number = 50):int</code><p>
 Devuelve aleatoriamente 0 ó 1 según la probabilidad estimada.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">prob</span>:Number</code> (default = <code>50</code>)<code></code> &mdash; % de probabilidad que salga 1
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>int</code> &mdash; Number
 </td>
</tr>
</table>
</div>
<a name="randomBool()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomBool</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomBool(prob:Number = 50):Boolean</code><p>
 Devuelve un valor booleano aleatorio según la probabilidad estimada.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">prob</span>:Number</code> (default = <code>50</code>)<code></code> &mdash; % de probabilidad que salga <code>true</code>
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Boolean</code> &mdash; Boolean
 </td>
</tr>
</table>
</div>
<a name="randomGreyColor()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomGreyColor</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomGreyColor(min:uint = 255, max:uint = 0):uint</code><p>
  Devuelve un valor entero sin signo aleatorio correspondiente a una gama de color gris, del blanco al negro.
  El rango de valores va del 0 (negro) al 255 (blanco). 
  </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">min</span>:uint</code> (default = <code>255</code>)<code></code> &mdash; Valor inferior (o máximo si no se especifica <code>max</code>).
  </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">max</span>:uint</code> (default = <code>0</code>)<code></code> &mdash; Valor superior.
  </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>uint</code> &mdash; uint
  </td>
</tr>
</table>
</div>
<a name="randomHexColor()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomHexColor</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomHexColor():uint</code><p>
  Devuelve un entero sin signo aleatorio entre 0x0 y 0xFFFFFF.
  </p><p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>uint</code> &mdash; Un valor entre 0x0 y 0xFFFFFF
  </td>
</tr>
</table>
</div>
<a name="randomInt()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomInt</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomInt(min:int = 1, max:int = 0):int</code><p>
 Devuelve un valor entero aleatorio entre un valor mínimo y un valor máximo.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">min</span>:int</code> (default = <code>1</code>)<code></code> &mdash; Valor inferior (o máximo si no se especifica <code>max</code>)
 </td>
</tr>
<tr>
<td class="paramSpacer">&nbsp;</td>
</tr>
<tr>
<td width="20px"></td><td><code><span class="label">max</span>:int</code> (default = <code>0</code>)<code></code> &mdash; Valor superior
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>int</code> &mdash; int
 </td>
</tr>
</table>
</div>
<a name="randomSign()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">randomSign</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function randomSign(prob:Number = 50):int</code><p>
 Devuelve aleatoriamente -1 ó 1 según la probabilidad estimada.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">prob</span>:Number</code> (default = <code>50</code>)<code></code> &mdash; % de probabilidad que salga 1
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>int</code> &mdash; Number
 </td>
</tr>
</table>
</div>
<a name="toDegree()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">toDegree</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function toDegree(radianes:Number):Number</code><p>
 Convierte un valor en radianes a grados.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">radianes</span>:Number</code> &mdash; Radianes a convertir
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; Number
 </td>
</tr>
</table>
</div>
<a name="toRadian()"></a>
<table cellspacing="0" cellpadding="0" class="detailHeader">
<tr>
<td class="detailHeaderName">toRadian</td><td class="detailHeaderParens">()</td><td class="detailHeaderType">method</td><td class="detailHeaderRule">&nbsp;</td>
</tr>
</table>
<div class="detailBody">
<code>public static function toRadian(grados:Number):Number</code><p>
 Convierte un valor en grados a radianes.
 </p><span class="label">Parameters</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20px"></td><td><code><span class="label">grados</span>:Number</code> &mdash; Grados a convertir
 </td>
</tr>
</table>
<p></p>
<span class="label">Returns</span>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="20"></td><td><code>Number</code> &mdash; Number
 </td>
</tr>
</table>
</div>
<br>
<br>
<hr>
<br>
<p></p>
<center class="copyright">http://www.raohmaru.com</center>
</div>
</body>
</html>
<!--http://www.raohmaru.com-->
